import {Command} from '../constant';
import Taro from '@tarojs/taro';
import {Dispatch} from 'typings';
import {IAllReducerProps} from '../types';
import {getReducerData} from '@/redux/store';
import {extraPathsValue} from '@/redux/util';
import api from 'api';
export default (dispatch: Dispatch) => {
  let action = {
    commonChange(...param: any) {
      dispatch({
        type: Command.commonChange,
        payload: extraPathsValue(...arguments),
      });
    },
    async page(reset = false) {
      const {searchParams, list} = getData().main;
      const result = await api.SyntheticRechargeHistoryController.getHistoryPage(searchParams);
      action.commonChange('main.list', reset ? result.content : [...list, ...result.content]);
      action.commonChange('main.status', result.last ? 'end' : 'ready');
      // consoleresult
    },
  };
  return action;
};

function getData(): IAllReducerProps {
  return {
    main: getReducerData('packageISyntheticRechargeHistoryMain'),
  };
}

//create by moon https://github.com/creasy2010/moon
